package com.konne.nightmare.FastPublicOpinion.mvp.presenter;

import android.content.DialogInterface;

import com.blankj.utilcode.util.ActivityUtils;
import com.konne.nightmare.FastPublicOpinion.base.BaseMvpPresenter;
import com.konne.nightmare.FastPublicOpinion.bean.MembersBean;
import com.konne.nightmare.FastPublicOpinion.mvp.view.IAddOrDelStudentView;
import com.konne.nightmare.FastPublicOpinion.ui.dialog.QJAlertDialog;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * Create by ws.
 * on Data:2022/1/26  Time:下午 3:51.
 * description: ** .
 */
public class AddOrDelStudentPresenter extends BaseMvpPresenter<IAddOrDelStudentView> {
    private int type;

    public void init(int type) {
        if (type == 0) {//获取未分组数据

        } else {//获取当前组的数据

        }
        getView().updataStudent(testGetStudents());
    }

    private List<MembersBean> testGetStudents() {
        List<MembersBean> teachers = new ArrayList<>();
        MembersBean bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Fa7%2F57%2F85%2Fa757850a29db44013a12ae694c12490f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=16a15a471d03f722fb59921f8d847d1a");
        bean.setName("学生1");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.bq233.com%2Fkanqq%2Fpic%2Fupload%2F2018%2F0723%2F1532329172809328.jpg&refer=http%3A%2F%2Fimg.bq233.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=1f5daa4d0a127ba306e5b5c1a4228729");
        bean.setName("学生2");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Fa7%2F57%2F85%2Fa757850a29db44013a12ae694c12490f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=16a15a471d03f722fb59921f8d847d1a");
        bean.setName("学生1");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.bq233.com%2Fkanqq%2Fpic%2Fupload%2F2018%2F0723%2F1532329172809328.jpg&refer=http%3A%2F%2Fimg.bq233.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=1f5daa4d0a127ba306e5b5c1a4228729");
        bean.setName("学生2");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Fa7%2F57%2F85%2Fa757850a29db44013a12ae694c12490f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=16a15a471d03f722fb59921f8d847d1a");
        bean.setName("学生1");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.bq233.com%2Fkanqq%2Fpic%2Fupload%2F2018%2F0723%2F1532329172809328.jpg&refer=http%3A%2F%2Fimg.bq233.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=1f5daa4d0a127ba306e5b5c1a4228729");
        bean.setName("学生2");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Fa7%2F57%2F85%2Fa757850a29db44013a12ae694c12490f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=16a15a471d03f722fb59921f8d847d1a");
        bean.setName("学生1");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.bq233.com%2Fkanqq%2Fpic%2Fupload%2F2018%2F0723%2F1532329172809328.jpg&refer=http%3A%2F%2Fimg.bq233.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=1f5daa4d0a127ba306e5b5c1a4228729");
        bean.setName("学生2");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Fa7%2F57%2F85%2Fa757850a29db44013a12ae694c12490f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=16a15a471d03f722fb59921f8d847d1a");
        bean.setName("学生1");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.bq233.com%2Fkanqq%2Fpic%2Fupload%2F2018%2F0723%2F1532329172809328.jpg&refer=http%3A%2F%2Fimg.bq233.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=1f5daa4d0a127ba306e5b5c1a4228729");
        bean.setName("学生2");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Fa7%2F57%2F85%2Fa757850a29db44013a12ae694c12490f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=16a15a471d03f722fb59921f8d847d1a");
        bean.setName("学生1");
        teachers.add(bean);
        bean = new MembersBean();
        bean.setAvatar("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.bq233.com%2Fkanqq%2Fpic%2Fupload%2F2018%2F0723%2F1532329172809328.jpg&refer=http%3A%2F%2Fimg.bq233.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645609764&t=1f5daa4d0a127ba306e5b5c1a4228729");
        bean.setName("学生2");
        teachers.add(bean);
        return teachers;
    }

    public void addUserList(Set<MembersBean> set) {
        getView().finishAct();
    }

    public void removeUserList(Set<MembersBean> set) {
        StringBuilder sb = new StringBuilder();
        for (MembersBean data : set) {
            sb.append(data.getName())
                    .append(",");
        }
        String names = sb.toString();
        names = names.substring(0, names.length() - 1);
        new QJAlertDialog.Builder(ActivityUtils.getTopActivity())
                .setMsg(String.format("确定要将“%s”移出该组？", names))
                .setPositiveButton("移出", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        getView().finishAct();
                    }
                }).show();
    }
}
